package com.hzit.manager.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.api.domain.Seller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.hzit.manager.service.ISellerService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 商家审核Controller
 * 
 * @author wf
 * @date 2024-01-15
 */
@RestController
@RequestMapping("/seller")
public class SellerController extends BaseController
{
    @Autowired
    private ISellerService sellerService;

    /**
     * 查询商家审核列表
     */
        @GetMapping("/list")
    public TableDataInfo list(Seller seller)
    {
        startPage();
        List<Seller> list = sellerService.selectSellerList(seller);
        return getDataTable(list);
    }

    /**
     * 导出商家审核列表
     */
        @Log(title = "商家审核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Seller seller)
    {
        List<Seller> list = sellerService.selectSellerList(seller);
        ExcelUtil<Seller> util = new ExcelUtil<Seller>(Seller.class);
        util.exportExcel(response, list, "商家审核数据");
    }

    /**
     * 获取商家审核详细信息
     */
        @GetMapping(value = "/{sellerId}")
    public AjaxResult getInfo(@PathVariable("sellerId") String sellerId)
    {
        return AjaxResult.success(sellerService.selectSellerBySellerId(sellerId));
    }

    /**
     * 新增商家审核
     */
        @Log(title = "商家审核", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Seller seller)
    {
        return toAjax(sellerService.insertSeller(seller));
    }

    /**
     * 修改商家审核
     */
        @Log(title = "商家审核", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Seller seller)
    {
        return toAjax(sellerService.updateSeller(seller));
    }

    /**
     * 删除商家审核
     */
        @Log(title = "商家审核", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sellerIds}")
    public AjaxResult remove(@PathVariable String[] sellerIds)
    {
        return toAjax(sellerService.deleteSellerBySellerIds(sellerIds));
    }
}
